package com.sskj.mine.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.SPUtil;
import com.sskj.lib.SPConfig;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.mine.bean.LoginBean;
import com.sskj.mine.http.HttpConfig;
import com.sskj.mine.ui.activity.MineLoginActivity;


public class MineLoginActivityPresenter extends BasePresenter<MineLoginActivity> {


    /**
     * 登录
     *
     * @param mobile 账号
     * @param opwd   密码
     * @return
     */
    public void login(String mobile, String opwd) {
        httpService.login(mobile, opwd).execute(new JsonCallBack<HttpData<LoginBean>>(this) {
            @Override
            public void onSuccess(Response<HttpData<LoginBean>> response) {
                HttpData<LoginBean> httpData = response.body();
                if (httpData.getStatus() == HttpConfig.OK) {
                    SPUtil.put(SPConfig.MOBILE, mobile);
                    mView.loginSuccess(httpData.getData());
                }
            }
        });
    }

    /**
     * 指纹登录验证密码
     *
     * @param opwd 密码
     * @return
     */
    public void checkFingerPwd(String opwd) {
        httpService.checkFingerPwd(opwd).execute(new JsonCallBack<HttpData<LoginBean>>() {
            @Override
            public void onSuccess(Response<HttpData<LoginBean>> response) {
                HttpData<LoginBean> httpData = response.body();
                if (httpData.getStatus() == HttpConfig.OK) {

                }
            }
        });
    }
}
